{%TEMPLATE->struct/head%}
{%TEMPLATE->struct/menu%}
<h2>My Account ([[htmlentities([[user.getUsername()]], ENT_QUOTES, "UTF-8")]])</h2>
{%TEMPLATE->struct/messages%}
<div class="card">
  <div class="table-responsive">
    <table class="table table-bordered">
		  <tr>
			  <th>User type</th>
			  <td>
				  [[group.getGroupName()]]
			  </td>
		  </tr>
		  <tr>
			  <th>Register date</th>
			  <td>
				  [[date([[config.getVal(DConfig::TIME_FORMAT)]], [[user.getRegisteredSince()]])]]
			  </td>
		  </tr>
		  <tr>
			  <th>Email address</th>
			  <td>
				  <form class='form-inline' action="account.php" method="post">
					  <input type='hidden' name='action' value='[[$DAccountAction::SET_EMAIL]]'>
					  <input type='email' name='email' class='form-control' value='[[user.getEmail()]]' title="Email">&nbsp;&nbsp;
					  <input type="hidden" name="csrf" value="[[csrf]]">
            <button type="submit" class='btn {{IF [[toggledarkmode]] > 0}}btn-primary{{ELSE}}btn-light{{ENDIF}}' data-toggle="tooltip" data-placement="top" title="Set"><i class="fas fa-save" aria-hidden="true"></i></button>
				  </form>
			  </td>	
		  </tr>
		  <tr>
			  <th>Set session length</th>
			  <td>
				  <form class='form-inline' action="account.php" method="post">
					  <input type='hidden' name='action' value='[[$DAccountAction::UPDATE_LIFETIME]]'>
					  <input type='text' name='lifetime' class='form-control' value='[[user.getSessionLifetime()]]' title="Session Length">&nbsp; seconds &nbsp;
					  <input type="hidden" name="csrf" value="[[csrf]]">
            <button type="submit" class='btn {{IF [[toggledarkmode]] > 0}}btn-primary{{ELSE}}btn-light{{ENDIF}}' data-toggle="tooltip" data-placement="top" title="Set"><i class="fas fa-save" aria-hidden="true"></i></button>
				  </form>
			  </td>	
		  </tr>
		  <tr>
			  <th>Password</th>
			  <td>
				  <form class='form-inline' action="account.php" method="post">
					  <input type='hidden' name='action' value='[[$DAccountAction::CHANGE_PASSWORD]]'>
					  <input type='password' name='oldpass' class='form-control' placeholder='Old password here...'>&nbsp;&nbsp;
					  <input type='password' name='newpass' class='form-control' placeholder='New password here...'>&nbsp;&nbsp;
					  <input type='password' name='reppass' class='form-control' placeholder='Repeat password...'>&nbsp;&nbsp;
					  <input type="hidden" name="csrf" value="[[csrf]]">
					  <input type="submit" class='btn {{IF [[toggledarkmode]] > 0}}btn-primary{{ELSE}}btn-light{{ENDIF}}' value="Change Password">
				  </form>
			  </td>
		  </tr>
	  </table>
  </div>
</div>
<div class="card">
  <div class="table-responsive">
    <table class="table table-bordered">
		  <tr>
			  <td colspan="2">
				  <div class="alert alert-warning">
					  <b>Disclaimer:</b> Administrators cannot reset your OTP auth information if your key is lost.
				  </div>
			  </td>
		  </tr>
		  {{IF ![[Util::isYubikeyEnabled()]]}}
			  <tr>
				  <th>Yubikey OTP</th>
				  <td>
					  Yubikey is currently not configured.<br>
					  Please contact an admin as it needs to be enabled and set up on the server configuration.
				  </td>
			  </tr>
		  {{ELSE}}
			  <tr>
				  <th>Enable/Disable Yubikey OTP</th>
					  <td>
						  {{IF [[user.getYubikey()]] == 1}}
							  <form class='form-inline' action="account.php" method="post">
								  Yubikey OTP currently enabled
								  <input type='hidden' name='action' value='[[$DAccountAction::YUBIKEY_DISABLE]]'>
								  <input type="hidden" name="csrf" value="[[csrf]]">
								  <input type="submit" class='btn btn-warning' value="Disable">
							  </form>
						  {{ELSE}}
							  <form class='form-inline' action="account.php" method="post">
								  Yubikey OTP is currently disabled
								  <input type='hidden' name='action' value='[[$DAccountAction::YUBIKEY_ENABLE]]'>
								  <input type="hidden" name="csrf" value="[[csrf]]">
								  <input type="submit" class='btn btn-success' value="Enable">
							  </form>
						  {{ENDIF}}
					  </td>
			  </tr>
			  <tr>
				  <th>OTP KEY 1:</th>
				  <td>
					  <form class='form-inline' action="account.php" method="post">
						  <input type='hidden' name='action' value='[[$DAccountAction::SET_OTP1]]'>
						  <input type='text' name='otp1' class='form-control' value='[[user.getOtp1()]]' title="OTP Key">&nbsp;&nbsp;
						  <input type="hidden" name="csrf" value="[[csrf]]">
						  <input type="submit" class='btn {{IF [[toggledarkmode]] > 0}}btn-primary{{ELSE}}btn-light{{ENDIF}}' value="Update">
					  </form>
				  </td>
			  </tr>
			  <tr>
				  <th>OTP KEY 2:</th>
				  <td>
					  <form class='form-inline' action="account.php" method="post">
						  <input type='hidden' name='action' value='[[$DAccountAction::SET_OTP2]]'>
						  <input type='text' name='otp2' class='form-control' value='[[user.getOtp2()]]' title="OTP Key">&nbsp;&nbsp;
						  <input type="hidden" name="csrf" value="[[csrf]]">
						  <input type="submit" class='btn {{IF [[toggledarkmode]] > 0}}btn-primary{{ELSE}}btn-light{{ENDIF}}' value="Update">
					  </form>
				  </td>
			  </tr>
			  <tr>
				  <th>OTP KEY 3:</th>
				  <td>
					  <form class='form-inline' action="account.php" method="post">
						  <input type='hidden' name='action' value='[[$DAccountAction::SET_OTP3]]'>
						  <input type='text' name='otp3' class='form-control' value='[[user.getOtp3()]]' title="OTP Key">&nbsp;&nbsp;
						  <input type="hidden" name="csrf" value="[[csrf]]">
						  <input type="submit" class='btn {{IF [[toggledarkmode]] > 0}}btn-primary{{ELSE}}btn-light{{ENDIF}}' value="Update">
					  </form>
				  </td>
			  </tr>
			  <tr>
				  <th>OTP KEY 4:</th>
				  <td>
					  <form class='form-inline' action="account.php" method="post">
						  <input type='hidden' name='action' value='[[$DAccountAction::SET_OTP4]]'>
						  <input type='text' name='otp4' class='form-control' value='[[user.getOtp4()]]' title="OTP Key">&nbsp;&nbsp;
						  <input type="hidden" name="csrf" value="[[csrf]]">
						  <input type="submit" class='btn {{IF [[toggledarkmode]] > 0}}btn-primary{{ELSE}}btn-light{{ENDIF}}' value="Update">
					  </form>
				  </td>
			  </tr>
		  {{ENDIF}}
	  </table>
  </div>
</div>
{{IF [[sizeof([[keys]])]] > 0}}
	<h3>API Access</h3>
	<div class="card">
		<div class="table-responsive">
	  		<table class="table table-bordered">
				<tbody>
					<tr>
						<th>Keys</th>
						<td>
							{{FOREACH key;[[keys]]}}
								[[key.getAccessKey()]]<br>
							{{ENDFOREACH}}
						</td>
					</tr>
				</tbody>
			</table>
		</div>
  	</div>
{{ENDIF}}
{%TEMPLATE->struct/foot%}
